package com.istock.union.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
@ImportResource("classpath:spring-mvc.xml")
@ComponentScan("com.istock.user.controller,com.istock.union.controller")
public class WebConfig extends WebMvcConfigurerAdapter {

	@Override
    public void addViewControllers(ViewControllerRegistry registry)
    {
        registry.addViewController("/").setViewName("forward:toIndex");
    }

	//如果使用jackson,请配置date的输出格式
	/*@Override
	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
		FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
		List<MediaType> mediaList = new ArrayList<MediaType>();
		mediaList.add(MediaType.APPLICATION_JSON);
		mediaList.add(MediaType.TEXT_HTML);
		mediaList.add(MediaType.TEXT_PLAIN);
		mediaList.add(new MediaType("application", "*+json"));
		converter.setSupportedMediaTypes(mediaList);
		FastJsonConfig jsonConfig = new FastJsonConfig();
		jsonConfig.setSerializerFeatures(SerializerFeature.WriteDateUseDateFormat);
		converters.add(converter);
	}*/

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
		registry.addResourceHandler("/favicon.ico").addResourceLocations("classpath:/static/");
	}
	
}
